In this project we are looking a prototype of an automated section-control blower sprayer (ASCS) which is currently being tested at Competence Centre for Fruit Production Lake Constance (Kompetenzzentrum Obstbau Bodensee, KOB) in its first season. It is compared on a monetary background to a manual section-control blower sprayer (MSCS) which is the current standard technology for spraying pesticides in orchards.
The most basic decision to make is whether the reduction of running-costs of the ASCS through lower pesticide usage compared to the MSCS are higher than the increased initial investment for the more expensive sprayer.
Other factors taken into consideration are the influence the reduction of pesticide application has on the biodiversity and water contamination. These factors influence the likelihood of the government setting a restriction on the maximum amount of pesticide allowed to be applied. In addition, these factors influence the customer behavior.
The output of the model generated in this project will be a monetary value for the farmer’s profit per hectare, calculated based on the investment costs, running costs, damage to the fruits (apples) - calculated by combining applied pesticides (with a potential limit) and influences of the increased or decreased biodiversity - and the customer behavior.
Reducing the use of pesticides in agricultural and horticultural production has been an important concern of policymakers, NGO, and also farmers for years. Not only is a reduction economically favourable on a farm level, but more and more negative impacts of the liberal use of agrochemicals on ecosystems have been reported recently. In orcharding, efforts have been made to make pesticide application more efficient in order to bring down the overall amount applied while still securing fruit quality and stable yields. This led to the advent of blower sprayers capable of section control. This feature allows the operator to reduce or completely turn off the application of pesticides on a part of the total working width when it is appropriate. For instance, if a shorter tree comes up in a row of taller trees, the operator will manually turn off the topmost section of the blower sprayer to prevent pesticide being sprayed past the treetop into the environment.
While the manually-operated section control sprayer (MSCS) is generally able to reduce pesticide application rates while maintaining the effectiveness of the agent where it is needed, the strain it puts on the operator is exhausting and requires properly trained and experienced personnel. This limits the overall work capacity of one unit. Furthermore, because of the complex handling, errors are likely to occur which diminishes the potential to reduce the ingress of agrochemicals into the environment.
Therefore, a novel technology is currently under development to automate the modulation of the section control feature of orchard sprayers. Light detection and ranging (LiDAR) sensors are mounted to the sprayer to allow a computer to assess the structure of the upcoming trees. This, in turn, enables the machine to appropriately adapt the individual sections to the current requirements. Besides the immediate relief for the tractor driver, this technology also allows less experienced workers to safely spray pesticide in orchards. Therefore, an automatically-controlled section control sprayer (ASCS) has a higher work capacity than a MSCS, i.e. a larger area can be sprayed in a given amount of time. Apart from that, pesticide reduction can be improved due to the higher precision in modulating the application rate following the principle of “as little as possible, as much as necessary.”
All in all, the ASCS promises to a more efficient application of pesticide and higher work capacity per sprayer, as well as less contamination of the environment while maintaining full effectiveness in terms of plant protection.
The two alternatives
Decision alternative 1: Buying an automated section control sprayer for orchards
This decision alternative has one main cost and some advantages for the future and the environment.
The main cost incurred when buying the automated section control sprayer, because of the sensors which enable the section control sprayer to regulate the application of the pesticides automatically when they are needed.
This option can have the advantage to decrease the needed plant protection which result in some positive effects on the environment like increasing the biodiversity, decreasing the water contamination and decrease the pests and diseases of the apple trees.
The benefits were derived from possibly having a bigger harvest and less losses due to pest and diseases. They can also derive from not getting sanctioned by governmental restrictions concerning about too much application of pesticides.
Decision alternative 2: Buying a manual section control sprayer for orchards.
Within this decision alternative the farmer buys a manual section control sprayer where the implementation cost incurred, but less than for the first alternative. The farmer must control the application of plant protection by hand and can have the disadvantage of applying more pesticide than needed.
The benefits are derived from the harvest and selling price, but the advantages of not getting sanctioned or increasing the biodiversity and the harvest can`t took place.
Reducing pesticide use: An analysis on the decision whether to implement an automated or manually operated section control sprayer in orchards.
: (describe further) * Farmer + importance: very high + Main Decision maker + Operator / User (knowledge about relevant orchards) + Budget for purchasing costs + profitable longterm?
Manufacturer
importance: (very) low
Supplier
(takes feedback into account)
Government
importance: medium - high
Bund/Länder - Arbeitsgemeinschaft Wasser (LAWA), Landwirtschaftskammer …
Reduction of pesticide residues and unwanted effects
taking probes from products, groundwater, biodiversity (short & longterm)
Consumers
importance: low - mid
no residues on products
inclined to buy farmers products
Food retailers
same as consumers
Society
importance: low - mid
no active influence / Public image
\(\Rightarrow\) influencing government decisions (mindset about eg. Biodiversity)
NGOs
importance: mid
Greenpeace, newspaper organizations, research centers / institutes
influencing society, consumers, government
newspaper, magazine article
Water suppliers
importance: mid
conservation of healthy water bodies
food chains (plankton), fishing grounds, drinking water
Agro-chemical companies
importance: low
keeping residues in environment low to prevent restrictive legislation (longterm)
BUT less sales of plant protection agents (shortterm)
Local biodiversity
importance: high
higher diversity
more pollinators
reduces chance of diseases
Beekeepers
importance: low - mid
less potential harm to bees
For the decision-relevant questions, we consulted various stakeholders as experts for our model. We consulted several experimental managers from different apple growing regions in Germany, Leaders and technical assistants from the area of plant health, plant protection and production technology of the Competence Centre for Fruit Production Lake Constance, as well as fruit grower from the Lake Constance region.
For a decision analysis it is important to known how valuable the given estimates are because it need to be based on comprehensive and reliable data. Therefore, calibration training is applied.
Calibration is a process to find out and document how the deviation of measuring device is. Due to Calibration training the affective answering behavior is reduced and it helps to improve the given estimates. It can also help to know your uncertainties and to train to give good estimates.
In this case experts are used as measuring device for good estimates. The answers are normally linked to various cognitive biases and normally lead to an overconfidence of the experts about their estimates.
To reduce this, a series of basic questions is used. In the first part of the calibration training the persons to be calibrated need to answer questions where the correct answer must be within a range. In the second part they need to answer yes or no questions and they need to estimate their confidence about the given answers. after answering the basic questions, they get the feedback about the given answers. This led to a reduction of overconfidence.
After the calibration training, they were asked about estimates to all inputs for the model with a 90% confidence interval.
The following graph is meant to give a better understanding of our model. We included two different sprayers, the automated and the manual sprayer seen on the far left of the model. Those effect mainly the amount of needed pesticides and plant protection agents but also the initial cost. Pesticides are the main factor in our model. They effect water contamination, biodiversity, plant damage and the cost through the amount applied.
We chose the duration of our model to be 10 years since most farmers replace their sprayers around this time and it had to be partly iterative, since most variables have an effect on the following years.
One Example for this is the amount we spray and the plant damage. If the farmer sprayed enough then there won’t be any damage, but if he or she estimated the amount incorrectly and sprayed less then needed then the plant damage in the following year will be effected. Something similar can be said about the customers. If we spray a lot then the water contamination increases and the biodiversity on the field decreases, this change is being picked up by the customers through the news, magazines or first hand if they are residents nearby.
Existing plant damage and fewer customers will reduce the harvest and thus lessen the fruit sales. The sales and minus the overall costs will create the farmers profit, the output variable we want to analyze.
Lastly we also included an event representing the government intervening in the amount we are allowed to spray. This has an impact especially in years the farmer has to spray a lot. Here the impact on the manual sprayer will be bigger as the automated sprayer reduces the overall amount of needed. The chance of the government intervening is set low, but is influenced by the water contamination and the biodiversity. We also included a delay between the government decision and the implementation of it. This delay can vary between two and six years, because various
model_flow_chart <- grViz("
digraph {
# Add general information which counts for everything!!!
# ---------
# Change flow chart orientation (top down: 'TD'; left to right: 'LR'
rankdir = 'LR'
# Add graph statements
graph [#label = 'Initial Model',
labelloc = t,
fontsize = 45,
ranksep=2,
nodesep=1]
# Add node statements
node [fontname = Arial,
fontcolor = black,
color = darkslategray,
penwidth = 1]
# Add edge statements
edge [fontsize=30,
penwidth=2,
fontname=Arial]
# ---------
# ---------
# create 'ranks' (basically nodes) for arranging nodes later on
rank1 [style=invis]
rank2 [style=invis]
rank3 [style=invis]
rank4 [style=invis]
rank5 [style=invis]
# make invisible (white) links between them
rank1->rank2->rank3->rank4->rank5 [color=white]
# ---------
# ---------
# Add specific statements for node group {Intervention & Alternatives}
node [shape = box,
fontsize = 30,
fixedsize = true,
width = 3.6,
height = 1.5]
Ascs [label = 'Automated section \n control sprayer'];
Al1 [label = 'Manual section \n control sprayer'];
# ---------
# Add specific statements for node group {Pesticides & Cost}
# ---------
node [shape = box,
fontsize = 28,
fixedsize = true,
width = 2.8,
height = 0.9]
Pe [label = 'Pesticides'];
Co [label = 'Cost']
Cu [label = 'Customers'];
Di [label = 'Plant damage'];
Bio [label = 'Biodiversity'];
WC [label = 'Water \n contamination'];
FS [label = 'Fruit sales'];
GC [label = 'Government \n concerns'];
FP [label = 'Farmers profit']
# ---------
# Add edge statements for negative connection (arrows) and add the connections
# ---------
edge [label = '- ',
fontcolor = 'red',
color = 'red']
{Ascs Al1} -> Pe #[headport = w, tailport = e]
GC -> Pe
Pe->Bio #[headport = w]
Pe-> Di
Bio->{Di GC}
WC->{Bio Cu}
Di->FS
Co->FP
# ---------
# Add edge statements for positive connection (arrows) and add the connections
# ---------
edge [label = '+',
fontcolor = 'forestgreen',
color = 'forestgreen']
{Ascs Al1}->Co #[headport = w, tailport = s]
Pe-> WC #[headport = w, tailport = n]
Pe-> Co
FS->FP
WC->GC
Bio-> Cu
# Di -> Pe
Cu->FS
# ---------
# ---------
# sorting the nodes per rank
{
Ascs -> Al1 -> rank1 [style=invis];
rank=same;
rankdir=TD;
}
{
Co -> Pe -> GC -> rank2 [style=invis];
rank=same;
rankdir=TD;
}
{
Di -> Bio -> WC -> rank3 [style=invis];
rank=same;
rankdir=TD;
}
{
Cu -> FS -> rank4 [style=invis];
rank=same;
rankdir=TD;
}
# {
# rank5 -> FS [style=invis];
# rank=same;
# rankdir=DT;
# }
#
# ---------
}")
testtesttesttest
As a reference we added the whole model code with short comments to make it a bit more readable.
>>>>>>> f1338f7eb4eff9c2c17ede5e7626aaf41ad7d52f# Importing and adjusting input table
input_table <- read.csv("data/input_data_03.csv", sep = ";", dec = ",", stringsAsFactors = FALSE)
input_table <- drop_na(input_table, c("lower","upper"))
input_table <- filter(input_table, !variable == "initial_aut_cost", !variable == "pesticide_quantity")
input_table <- input_table[ order(input_table$distribution, input_table$variable), ]
write.csv(input_table, "data/final/inputs.csv", row.names = FALSE)
input_table <- read.csv("data/final/inputs.csv", stringsAsFactors = FALSE)
ascs_decision_model <- function(x, varnames){
# table for iterative impacted variables
auxiliary_table <- data.frame(year = c(1:n_years),
pest_quant_man = rep(0.,n_years),
pest_quant_aut = rep(0.,n_years),
rel_water_cont_man = rep(0.,n_years),
rel_water_cont_aut = rep(0.,n_years),
rel_bio_man = rep(0.,n_years),
rel_bio_aut = rep(0.,n_years),
plant_dmg_pot_man = rep(0.,n_years),
plant_dmg_pot_aut = rep(0.,n_years),
actual_plant_dmg_man = rep(0.,n_years),
actual_plant_dmg_aut = rep(0.,n_years),
gov_inter_chance_man = rep(0.,n_years),
gov_inter_chance_aut = rep(0.,n_years),
gov_inter_happened_man = rep(0,n_years),
gov_inter_happened_aut = rep(0,n_years),
gov_reaction = rep(0,n_years)
)
for (y in 1:n_years) {
if (y == 1) { # first year
# fix for one run
## generating a vector for the government reaction delay
lower <- input_table[input_table$variable == "government_reaction_time", "lower"]
upper <- input_table[input_table$variable == "government_reaction_time", "upper"]
auxiliary_table$gov_reaction <- round(runif(n_years,lower,upper))
# general chance that government intervenes
# in year 1 this is covered by (pre-)assumptions
## will be affected by biodiversity and water contamination later on
auxiliary_table$gov_inter_chance_man[y] <- government_intervention_chance
auxiliary_table$gov_inter_chance_aut[y] <- auxiliary_table$gov_inter_chance_man[y]
# chance event of government intervention takes only place if the reaction
# delay is inside our n_years boundaries
if ((y + auxiliary_table$gov_reaction[y]) <= n_years) {
auxiliary_table$gov_inter_happened_man[y + auxiliary_table$gov_reaction[y]] <-
chance_event(auxiliary_table$gov_inter_chance_man[y], 1, 0)
auxiliary_table$gov_inter_happened_aut[y + auxiliary_table$gov_reaction[y]] <-
chance_event(auxiliary_table$gov_inter_chance_aut[y], 1, 0)
}
# influence factor from pesticides on water contamination ## fix per run
pest_cont_fac <- vv(pesticide_on_water_contamination_factor, var_CV, 1)
# influence factor from pesticides on biodiversity ## fix per run
pest_bio_fac <- vv(pesticide_on_biodiversity_factor, var_CV, 1)
# influence factor from water contamination on biodiversity ## fix per run
cont_bio_fac <- vv(water_contamination_on_biodiversity_factor, var_CV, 1)
# pesticide reduction factor when using the automated sprayer
pest_red_fac <- pesticide_reduction_auto
# potential plant damage vector for n_years
# its the same for both decisions
## will be affected by biodiversity later on
auxiliary_table$plant_dmg_pot_man <- vv(potential_plant_damage, potential_plant_damage_CV, n_years)
auxiliary_table$plant_dmg_pot_aut <- auxiliary_table$plant_dmg_pot_man
# manual correlation between pesticide quantity and potential plant damage
## the farmer tries to assess how much plant damage there will be and sets
## the applied pest quantity accordingly
lower <- input_table[input_table$variable == "farmers_pesticide_quantity_miscalculation", "lower"]
upper <- input_table[input_table$variable == "farmers_pesticide_quantity_miscalculation", "upper"]
auxiliary_table$pest_quant_man <- auxiliary_table$plant_dmg_pot_man *
rposnorm90ci(n_years, lower = lower, upper = upper)
auxiliary_table$pest_quant_aut <- auxiliary_table$pest_quant_man *
pest_red_fac
# biodiversity and water contamination are 1 in the first year ("status quo")
auxiliary_table$rel_water_cont_man[y] <- 1
auxiliary_table$rel_water_cont_aut[y] <- 1
auxiliary_table$rel_bio_man[y] <- 1
auxiliary_table$rel_bio_aut[y] <- 1
# actual plant damage
## actual plant damage = potential plant damage - quantity sprayed
## the automated needs less spraying to counter the same amount
## of potential plant damage (/ pest_red_fac)
actual_plant_dmg_man <- auxiliary_table$plant_dmg_pot_man[y] -
auxiliary_table$pest_quant_man[y]
auxiliary_table$actual_plant_dmg_man[y] <- ifelse(actual_plant_dmg_man < 0,
0,
actual_plant_dmg_man)
actual_plant_dmg_aut <- auxiliary_table$plant_dmg_pot_aut[y] -
auxiliary_table$pest_quant_aut[y] / pest_red_fac
auxiliary_table$actual_plant_dmg_aut[y] <- ifelse(actual_plant_dmg_aut < 0,
0,
actual_plant_dmg_aut)
}else { # ongoing years (year 2 - n_years)
## the values change per year so the influence changes as well
# government intervention chance
## general chance affected by biodiversity and water contamination
auxiliary_table$gov_inter_chance_man[y] <- auxiliary_table$gov_inter_chance_man[y-1] +
( ((1 - auxiliary_table$rel_bio_man[y-1]) * biodiversity_on_gov_concern) +
((auxiliary_table$rel_water_cont_man[y-1] - 1) * water_contamination_on_gov_concern))
auxiliary_table$gov_inter_chance_aut[y] <- auxiliary_table$gov_inter_chance_aut[y-1] +
( ((1 - auxiliary_table$rel_bio_aut[y-1]) * biodiversity_on_gov_concern) +
((auxiliary_table$rel_water_cont_aut[y-1] - 1) * water_contamination_on_gov_concern))
# checking if the chance is really between 0 and 1 so the chance_event function works
auxiliary_table$gov_inter_chance_man[y] <- ifelse(auxiliary_table$gov_inter_chance_man[y] <= 0,
0,
ifelse(auxiliary_table$gov_inter_chance_man[y] >= 1,
1,
auxiliary_table$gov_inter_chance_man[y]))
auxiliary_table$gov_inter_chance_aut[y] <- ifelse(auxiliary_table$gov_inter_chance_aut[y] <= 0,
0,
ifelse(auxiliary_table$gov_inter_chance_aut[y] >= 1,
1,
auxiliary_table$gov_inter_chance_aut[y]))
# chance_event function
## only applies if the value for the intervention delay + the current year is still inside the n_years boarder &
### there was no intervention in the previous years
### there was no intervention in the relevant year already
if(auxiliary_table$gov_inter_happened_man[y-1] == 0){
if(y + auxiliary_table$gov_reaction[y] <= n_years){
if(auxiliary_table$gov_inter_happened_man[y + auxiliary_table$gov_reaction[y]] == 0){
auxiliary_table$gov_inter_happened_man[y + auxiliary_table$gov_reaction[y]] <-
chance_event(auxiliary_table$gov_inter_chance_man[y], 1, 0)
}
}
}else{
auxiliary_table$gov_inter_happened_man[y] <- 1
}
if(auxiliary_table$gov_inter_happened_aut[y-1] == 0){
if(y + auxiliary_table$gov_reaction[y] <= n_years){
if(auxiliary_table$gov_inter_happened_aut[y + auxiliary_table$gov_reaction[y]] == 0){
auxiliary_table$gov_inter_happened_aut[y + auxiliary_table$gov_reaction[y]] <-
chance_event(auxiliary_table$gov_inter_chance_aut[y], 1, 0)
}
}
}else{
auxiliary_table$gov_inter_happened_aut[y] <- 1
}
# water contamination
## assuming that the pesticide quantity influences the water contamination by pest_cont_fac
auxiliary_table$rel_water_cont_man[y] <- auxiliary_table$rel_water_cont_man[y-1] +
((auxiliary_table$pest_quant_man[y-1] - 1) * pest_cont_fac)
auxiliary_table$rel_water_cont_aut[y] <- auxiliary_table$rel_water_cont_aut[y-1] +
((auxiliary_table$pest_quant_aut[y-1] - 1) * pest_cont_fac)
# biodiversity
## assuming that the pesticides influences the biodiversity by pest_bio_fac
## assuming that the water contamination influences the biodiversity by cont_bio_fac
auxiliary_table$rel_bio_man[y] <- auxiliary_table$rel_bio_man[y-1] +
((1 - auxiliary_table$pest_quant_man[y-1]) * pest_bio_fac) +
((1 - auxiliary_table$rel_water_cont_man[y-1]) * cont_bio_fac)
auxiliary_table$rel_bio_aut[y] <- auxiliary_table$rel_bio_aut[y-1] +
((1 - auxiliary_table$pest_quant_aut[y-1]) * pest_bio_fac) +
((1 - auxiliary_table$rel_water_cont_aut[y-1]) * cont_bio_fac)
# potential plant damage
## effected by biodiversity
auxiliary_table$plant_dmg_pot_man[y] <- auxiliary_table$plant_dmg_pot_man[y] +
auxiliary_table$plant_dmg_pot_man[y] * (1 - auxiliary_table$rel_bio_man[y])
auxiliary_table$plant_dmg_pot_aut[y] <- auxiliary_table$plant_dmg_pot_aut[y] +
auxiliary_table$plant_dmg_pot_aut[y] * (1 - auxiliary_table$rel_bio_aut[y])
# pesticide quantity
## effected by biodiversity
auxiliary_table$pest_quant_man[y] <- auxiliary_table$pest_quant_man[y] +
auxiliary_table$pest_quant_man[y] * (1 - auxiliary_table$rel_bio_man[y])
auxiliary_table$pest_quant_aut[y] <- (auxiliary_table$pest_quant_aut[y] +
auxiliary_table$pest_quant_aut[y] * (1 - auxiliary_table$rel_bio_aut[y]))
# influence of chance_event
auxiliary_table$pest_quant_man[y] <- ifelse(auxiliary_table$gov_inter_happened_man[y] == 0,
auxiliary_table$pest_quant_man[y],
ifelse(auxiliary_table$pest_quant_man[y] >
government_pesticide_quantity,
government_pesticide_quantity,
auxiliary_table$pest_quant_man[y]))
auxiliary_table$pest_quant_aut[y] <- ifelse(auxiliary_table$gov_inter_happened_aut[y] == 0,
auxiliary_table$pest_quant_aut[y],
ifelse(auxiliary_table$pest_quant_aut[y] >
government_pesticide_quantity,
government_pesticide_quantity,
auxiliary_table$pest_quant_aut[y]))
# actual plant damage
## potential plant damage - pesticide quantity
actual_plant_dmg_man <- auxiliary_table$plant_dmg_pot_man[y] - auxiliary_table$pest_quant_man[y]
auxiliary_table$actual_plant_dmg_man[y] <- ifelse(actual_plant_dmg_man < 0,
0,
actual_plant_dmg_man)
actual_plant_dmg_aut <- auxiliary_table$plant_dmg_pot_aut[y] - auxiliary_table$pest_quant_aut[y] / pest_red_fac
auxiliary_table$actual_plant_dmg_aut[y] <- ifelse(actual_plant_dmg_aut < 0,
0,
actual_plant_dmg_aut)
}
}
# yields prizes are varying depending on the years and the plant damage
yield_t_ha <- vv(yield, var_CV, n_years)
yield_t_ha_man <- yield_t_ha * (1 - auxiliary_table$actual_plant_dmg_man)
yield_t_ha_aut <- yield_t_ha * (1 - auxiliary_table$actual_plant_dmg_aut)
# market prizes are varying over the years
market_price_e_t <- vv(market_price, var_CV, n_years)
# fruit sales depend on yield and market price
fruit_sales_e_ha_man <- yield_t_ha_man * market_price_e_t
fruit_sales_e_ha_aut <- yield_t_ha_aut * market_price_e_t
# costs for pesticides per ha and decision
pest_cost_ha_const <- vv( pesticide_cost, var_CV, n_years )
pest_cost_ha_man <- pest_cost_ha_const * auxiliary_table$pest_quant_man
pest_cost_ha_aut <- pest_cost_ha_const * auxiliary_table$pest_quant_aut
# machine costs are applied only once so n = 1
machine_cost_man <- c( initial_man_cost, rep( 0, (n_years-1) ) )
machine_cost_aut <- machine_cost_man + c( initial_upg_cost, rep( 0, (n_years-1) ) )
# customers influence
## influenced by biodiversity and water contamination on customers buying behaviour
customers_man <- rep(customer_on_fruitsales, n_years) +
(auxiliary_table$rel_bio_man - 1) * biodiversity_on_customer +
(1 - auxiliary_table$rel_water_cont_man) * water_contamination_on_customer
customers_aut <- rep(customer_on_fruitsales, n_years) +
(auxiliary_table$rel_bio_aut - 1) * biodiversity_on_customer +
(1 - auxiliary_table$rel_water_cont_aut) * water_contamination_on_customer
# profit - depends an the fruit sales and the pesticide costs per hectare
## resulting profit gets multiplied by the number of hectares (area_per_machine)
## for the automated option the machine upgrade cost get subtracted
farmers_profit_man = (fruit_sales_e_ha_man * customers_man - pest_cost_ha_man) *
area_per_machine - machine_cost_man
farmers_profit_aut = (fruit_sales_e_ha_aut * customers_aut - pest_cost_ha_aut) *
area_per_machine - machine_cost_aut
# NPV - the value of money in the future gets discounted
## 2 - 5 % since our farmers are likely to invest
NPV_aut = discount(farmers_profit_aut, discount_rate, calculate_NPV = TRUE)
NPV_man = discount(farmers_profit_man, discount_rate, calculate_NPV = TRUE)
return(list(Interv_NPV = NPV_aut,
NO_Interv_NPV = NPV_man,
NPV_decision_do = NPV_aut - NPV_man,
Cashflow_decision_do = farmers_profit_aut - farmers_profit_man))
}
In the following chapters we show and explain the code of our model chunk by chunk.
The first step in creating our model is to load in our input variables from the excel file.
We optionally tidy our file up with drop_na, filter, order and write the clean file to a new directory. Now we import the final excel file.
In the Script we often use the _man or _aut abbreviation as an suffix to indicate which sprayer variables we are modifying.
input_table <- read.csv("data/input_data_03.csv",sep = ";", dec = ",", stringsAsFactors = FALSE)
input_table <- drop_na(input_table, c("lower","upper"))
input_table <- filter(input_table, !variable == "initial_aut_cost", !variable == "pesticide_quantity")
input_table <- input_table[ order(input_table&distribution, input_table$variable), ]
write.csv(input_table, "data/final/inputs.csv", row.names = FALSE)
input_table <- read.csv("data/final/inputs.csv", stringsAsFactors = FALSE)
After we loaded in all our predefined variables we need to define the iterative variables. For this we start writing our function ascs_decision_model.
We created an auxiliary_table with n_years amount of rows and all the relevant variables in the columns, to make the calculations of the variables faster.
At this point we defined the values for each year as 0.
ascs_decision_model <- function(x, varnames){
auxiliary_table <- data.frame(year = c(1:n_years),
pest_quant_man = rep(0.,n_years),
pest_quant_aut = rep(0.,n_years),
rel_water_cont_man = rep(0.,n_years),
rel_water_cont_aut = rep(0.,n_years),
rel_bio_man = rep(0.,n_years),
rel_bio_aut = rep(0.,n_years),
plant_dmg_pot_man = rep(0.,n_years),
plant_dmg_pot_aut = rep(0.,n_years),
actual_plant_dmg_man = rep(0.,n_years),
actual_plant_dmg_aut = rep(0.,n_years),
gov_inter_chance_man = rep(0.,n_years),
gov_inter_chance_aut = rep(0.,n_years),
gov_inter_happened_man = rep(0,n_years),
gov_inter_happened_aut = rep(0,n_years),
gov_reaction = rep(0,n_years)
)
To iterate through each year we set for-loop to be n_years long. Furthermore we kept in mind that n_years can vary and kept our model dynamic and easily adaptable for other cases.
The next step in the for-loop is to overwrite all the iterative variables for the first year (if (y == 1). Here we change the government reaction to a number randomly derived from between the government_reaction_time boundaries from the input table. This delay is used later on and represents the time between the government decision and its implementation.
The chance that the government intervenes is covered by (pre-)assumptions for the first year, it is directly taken from the input table. In later years it will be effected by the biodiversity and water contamination.
We also make sure that the government intervention happens only inside the n_years boundaries.
for (y in 1:n_years) {
if (y == 1) {
lower <- input_table[input_table$variable == "government_reaction_time", "lower"]
upper <- input_table[input_table$variable == "government_reaction_time", "upper"]
auxiliary_table$gov_reaction <- round(runif(n_years,lower,upper))
auxiliary_table$gov_inter_chance_man[y] <- government_intervention_chance
auxiliary_table$gov_inter_chance_aut[y] <- auxiliary_table$gov_inter_chance_man[y]
if ((y + auxiliary_table$gov_reaction[y]) <= n_years) {
auxiliary_table$gov_inter_happened_man[y +
auxiliary_table$gov_reaction[y]] <- chance_event(
auxiliary_table$gov_inter_chance_man[y], 1, 0)
auxiliary_table$gov_inter_happened_aut[y +
auxiliary_table$gov_reaction[y]] <- chance_event(
auxiliary_table$gov_inter_chance_aut[y], 1, 0)
}
In the following part we use the vv() function to get values for the influence factors. Those include the influence from pesticides on water contamination and biodiversity but also from water contamination on biodiversity. Further we import the factor that describes how much reduction can be achieved by using the automated sprayer (pesticide_reduction_auto) from the input table.
pest_cont_fac <- vv(pesticide_on_water_contamination_factor, var_CV, 1)
pest_bio_fac <- vv(pesticide_on_biodiversity_factor, var_CV, 1)
cont_bio_fac <- vv(water_contamination_on_biodiversity_factor, var_CV, 1)
pest_red_fac <- pesticide_reduction_auto
To get to the actual plant damage we initially define a potential plant damage for every year. This potential damage will be effected by the amount of pesticides sprayed and the biodiversity changes in the following years.
Now we let the pesticide quantity correlate with the potential plant damage.
The idea here is that the farmer tries to spray enough but not to much. This estimation is prone to errors, so we chose to multiply the potential plant damage with a randomly drawn number from the 90% confidence interval of the borders defined in the farmers_pesticide_quantity_miscalculation variable.
The amount of pesticide usage for the automated sprayer is further multiplied by the pesticide reduction factor (pest_red_fac).
auxiliary_table$plant_dmg_pot_man <- vv(potential_plant_damage, potential_plant_damage_CV, n_years)
auxiliary_table$plant_dmg_pot_aut <- auxiliary_table$plant_dmg_pot_man
lower <- input_table[input_table$variable == "farmers_pesticide_quantity_miscalculation", "lower"]
upper <- input_table[input_table$variable == "farmers_pesticide_quantity_miscalculation", "upper"]
auxiliary_table$pest_quant_man <- auxiliary_table$plant_dmg_pot_man *
rposnorm90ci(n_years, lower = lower, upper = upper)
auxiliary_table$pest_quant_aut <- auxiliary_table$pest_quant_man * pest_red_fac
We decided that the biodiversity and water contamination will be relative and set it for the first year to 1. They will increase or decrease in the following years, depending on the pesticide usage.
The amount that was sprayed is subtracted from potential plant damage to get to the actual plant damage.
We made an optional check to make sure that the actual plant damage is not below zero.
auxiliary_table$rel_water_cont_man[y] <- 1
auxiliary_table$rel_water_cont_aut[y] <- 1
auxiliary_table$rel_bio_man[y] <- 1
auxiliary_table$rel_bio_aut[y] <- 1
actual_plant_dmg_man <- auxiliary_table$plant_dmg_pot_man[y] - auxiliary_table$pest_quant_man[y]
auxiliary_table$actual_plant_dmg_man[y] <- ifelse(actual_plant_dmg_man < 0, 0, actual_plant_dmg_man)
actual_plant_dmg_aut <- auxiliary_table$plant_dmg_pot_aut[y] - auxiliary_table$pest_quant_aut[y] / pest_red_fac
auxiliary_table$actual_plant_dmg_aut[y] <- ifelse(actual_plant_dmg_aut < 0, 0, actual_plant_dmg_aut)
For the following years (year 2 - n_years) a lot of variables are varying.
The first change is in the chance for the government intervention. This is depending on the variation in biodiversity and water contamination.
We also check for the chance being between 1 and 0.
}else {
auxiliary_table$gov_inter_chance_man[y] <- auxiliary_table$gov_inter_chance_man[y-1] +
( ((1 - auxiliary_table$rel_bio_man[y-1]) * biodiversity_on_gov_concern) +
((auxiliary_table$rel_water_cont_man[y-1] - 1) * water_contamination_on_gov_concern))
auxiliary_table$gov_inter_chance_aut[y] <- auxiliary_table$gov_inter_chance_aut[y-1] +
( ((1 - auxiliary_table$rel_bio_aut[y-1]) * biodiversity_on_gov_concern) +
((auxiliary_table$rel_water_cont_aut[y-1] - 1) * water_contamination_on_gov_concern))
auxiliary_table$gov_inter_chance_man[y] <- ifelse(auxiliary_table$gov_inter_chance_man[y] <= 0,
0,
ifelse(auxiliary_table$gov_inter_chance_man[y] >= 1,
1,
auxiliary_table$gov_inter_chance_man[y]))
auxiliary_table$gov_inter_chance_aut[y] <- ifelse(auxiliary_table$gov_inter_chance_aut[y] <= 0,
0,
ifelse(auxiliary_table$gov_inter_chance_aut[y] >= 1,
1,
auxiliary_table$gov_inter_chance_aut[y]))
Now for the chance_event function itself.
The event can only take place if the intervention delay added to the current year lies inside the n_years range and there was no intervention in the last year or in the relevant year already.
If the event takes place, then the amount of pesticides legally allowed to be sprayed will be changed to a fixed number for the relevant years and following. This will have an especially big impact on the manual sprayer, since the amount sprayed by the automated sprayer is always lower.
if(auxiliary_table$gov_inter_happened_man[y-1] == 0){
if(y + auxiliary_table$gov_reaction[y] <= n_years){
if(auxiliary_table$gov_inter_happened_man[y + auxiliary_table$gov_reaction[y]] == 0){
auxiliary_table$gov_inter_happened_man[y +
auxiliary_table$gov_reaction[y]] <- chance_event(auxiliary_table$gov_inter_chance_man[y], 1, 0)
}
}
}else{
auxiliary_table$gov_inter_happened_man[y] <- 1
}
if(auxiliary_table$gov_inter_happened_aut[y-1] == 0){
if(y + auxiliary_table$gov_reaction[y] <= n_years){
if(auxiliary_table$gov_inter_happened_aut[y + auxiliary_table$gov_reaction[y]] == 0){
auxiliary_table$gov_inter_happened_aut[y +
auxiliary_table$gov_reaction[y]] <- chance_event(auxiliary_table$gov_inter_chance_aut[y], 1, 0)
}
}
}else{
auxiliary_table$gov_inter_happened_aut[y] <- 1
}
To get the values of biodiversity and water contamination of the current year, we multiply the pesticide quantity from the last year with the respective influence factor and add it to the biodiversity and water contamination of last year. The current biodiversity is additionally influenced through the water contamination of the last year.
auxiliary_table$rel_water_cont_man[y] <- auxiliary_table$rel_water_cont_man[y-1] +
((auxiliary_table$pest_quant_man[y-1] - 1) * pest_cont_fac)
auxiliary_table$rel_water_cont_aut[y] <- auxiliary_table$rel_water_cont_aut[y-1] +
((auxiliary_table$pest_quant_aut[y-1] - 1) * pest_cont_fac)
auxiliary_table$rel_bio_man[y] <- auxiliary_table$rel_bio_man[y-1] +
((1 - auxiliary_table$pest_quant_man[y-1]) * pest_bio_fac) +
((1 - auxiliary_table$rel_water_cont_man[y-1]) * cont_bio_fac)
auxiliary_table$rel_bio_aut[y] <- auxiliary_table$rel_bio_aut[y-1] +
((1 - auxiliary_table$pest_quant_aut[y-1]) * pest_bio_fac) +
((1 - auxiliary_table$rel_water_cont_aut[y-1]) * cont_bio_fac)
The present potential plant damage and pesticide quantity get reduced by the newly calculated biodiversity. The idea here is that the pests get reduced through the higher biodiversity.
auxiliary_table$plant_dmg_pot_man[y] <- auxiliary_table$plant_dmg_pot_man[y] +
auxiliary_table$plant_dmg_pot_man[y] * (1 - auxiliary_table$rel_bio_man[y])
auxiliary_table$plant_dmg_pot_aut[y] <- auxiliary_table$plant_dmg_pot_aut[y] +
auxiliary_table$plant_dmg_pot_aut[y] * (1 - auxiliary_table$rel_bio_aut[y])
auxiliary_table$pest_quant_man[y] <- auxiliary_table$pest_quant_man[y] +
auxiliary_table$pest_quant_man[y] * (1 - auxiliary_table$rel_bio_man[y])
auxiliary_table$pest_quant_aut[y] <- (auxiliary_table$pest_quant_aut[y] +
auxiliary_table$pest_quant_aut[y] * (1 - auxiliary_table$rel_bio_aut[y]))
Since everything in the if-loop part is calculated for the first year only, the actual plant damage and the effect of the intervention must be calculated for the following years again.
auxiliary_table$pest_quant_man[y] <- ifelse(auxiliary_table$gov_inter_happened_man[y] == 0,
auxiliary_table$pest_quant_man[y],
ifelse(auxiliary_table$pest_quant_man[y] > government_pesticide_quantity,
government_pesticide_quantity,
auxiliary_table$pest_quant_man[y]))
auxiliary_table$pest_quant_aut[y] <- ifelse(auxiliary_table$gov_inter_happened_aut[y] == 0,
auxiliary_table$pest_quant_aut[y],
ifelse(auxiliary_table$pest_quant_aut[y] > government_pesticide_quantity,
government_pesticide_quantity,
auxiliary_table$pest_quant_aut[y]))
actual_plant_dmg_man <- auxiliary_table$plant_dmg_pot_man[y] - auxiliary_table$pest_quant_man[y]
auxiliary_table$actual_plant_dmg_man[y] <- ifelse(actual_plant_dmg_man < 0,
0,
actual_plant_dmg_man)
actual_plant_dmg_aut <- auxiliary_table$plant_dmg_pot_aut[y] - auxiliary_table$pest_quant_aut[y] / pest_red_fac
auxiliary_table$actual_plant_dmg_aut[y] <- ifelse(actual_plant_dmg_aut < 0,
0,
actual_plant_dmg_aut)
}
yield depending on the year and plant damage
market prices depending on the year
fruit sales depending on the yield and the market price
pesticide costs per hectare depending on the year
pesticide costs per hectare and sprayer depending additionally on the amount sprayed
machine costs depending on the brand, year, and if its automated or manual
customers depending on biodiversity and water contamination
profit depending on fruit sales, pesticide costs, hectare, customers and machine costs
yield_t_ha <- vv(yield, var_CV, n_years)
yield_t_ha_man <- yield_t_ha * (1 - auxiliary_table$actual_plant_dmg_man)
yield_t_ha_aut <- yield_t_ha * (1 - auxiliary_table$actual_plant_dmg_aut)
market_price_e_t <- vv(market_price, var_CV, n_years)
fruit_sales_e_ha_man <- yield_t_ha_man * market_price_e_t
fruit_sales_e_ha_aut <- yield_t_ha_aut * market_price_e_t
pest_cost_ha_const <- vv( pesticide_cost, var_CV, n_years )
pest_cost_ha_man <- pest_cost_ha_const * auxiliary_table$pest_quant_man
pest_cost_ha_aut <- pest_cost_ha_const * auxiliary_table$pest_quant_aut
machine_cost_man <- c( initial_man_cost, rep( 0, (n_years-1) ) )
machine_cost_aut <- machine_cost_man + c( initial_upg_cost, rep( 0, (n_years-1) ) )
customers_man <- rep(customer_on_fruitsales, n_years) +
(auxiliary_table$rel_bio_man - 1) * biodiversity_on_customer +
(1 - auxiliary_table$rel_water_cont_man) * water_contamination_on_customer
customers_aut <- rep(customer_on_fruitsales, n_years) +
(auxiliary_table$rel_bio_aut - 1) * biodiversity_on_customer +
(1 - auxiliary_table$rel_water_cont_aut) * water_contamination_on_customer
farmers_profit_man = (fruit_sales_e_ha_man * customers_man - pest_cost_ha_man) * area_per_machine - machine_cost_man
farmers_profit_aut = (fruit_sales_e_ha_aut * customers_aut - pest_cost_ha_aut) * area_per_machine - machine_cost_aut
The profits get discounted to generate the respective net present value. We chose a discount rate between 2 and 5 %, since our farmers are likely to invest.
In the end we return the calculated NPVs, the difference between the NPVs and the cashflow to further plot and analyze them.
NPV_aut = discount(farmers_profit_aut, discount_rate, calculate_NPV = TRUE)
NPV_man = discount(farmers_profit_man, discount_rate, calculate_NPV = TRUE)
return(list(Interv_NPV = NPV_aut,
NO_Interv_NPV = NPV_man,
NPV_decision_do = NPV_aut - NPV_man,
Cashflow_decision_do = farmers_profit_aut - farmers_profit_man))
}
Since looking at the outcome of the 10 year model only is not enough, we utilize the Monte Carlo simulation (mcSimulation()). We set the numberOfModelRuns to 10 000. This creates a big enough distribution to make an educated recommendation.
Lastly we also calculate the estimated value of perfect information (evpi) from a subset of our Monte Carlo simulation.
## Perform a Monte Carlo simulation
mcSimulation_results <- decisionSupport::mcSimulation(
estimate = as.estimate(input_table),
model_function = ascs_decision_model,
numberOfModelRuns = 10000,
functionSyntax = "plainNames"
)
# Here we subset the outputs from the mcSimulation function (y) by selecting the correct variables
mcSimulation_table <- data.frame(mcSimulation_results$x, mcSimulation_results$y[1:3])
evpi <- multi_EVPI(mc = mcSimulation_table, first_out_var = "Interv_NPV")
## [1] "Processing 3 output variables. This can take some time."
## [1] "Output variable 1 (Interv_NPV) completed."
## [1] "Output variable 2 (NO_Interv_NPV) completed."
## [1] "Output variable 3 (NPV_decision_do) completed."
## Plot Net Present Value (NPV) distributions
compare_decisions <- decisionSupport::plot_distributions(mcSimulation_object = mcSimulation_results,
vars = c("Interv_NPV", "NO_Interv_NPV"),
method = 'smooth_simple_overlay',
base_size = 7)
compare_boxplot <- decisionSupport::plot_distributions(mcSimulation_object = mcSimulation_results,
vars = c("Interv_NPV",
"NO_Interv_NPV"),
method = 'boxplot')
decision_do <- decisionSupport::plot_distributions(mcSimulation_object = mcSimulation_results,
vars = "NPV_decision_do",
method = 'boxplot_density')
cashflow <- plot_cashflow(mcSimulation_object = mcSimulation_results, cashflow_var_name = "Cashflow_decision_do")
cashflow <- cashflow + scale_x_continuous(breaks = seq(0,10,2),expand = c(0,0))
## Scale for 'x' is already present. Adding another scale for 'x', which will
## replace the existing scale.
## Projection to Latent Structures (PLS) analysis
pls_result <- plsr.mcSimulation(object = mcSimulation_results,
resultName = names(mcSimulation_results$y)[3], ncomp = 1)
pls <- plot_pls(pls_result, input_table = data.frame(variable = input_table$variable, label = input_table$label), threshold = 0.9)
## Value of information (VoI) analysis
evpi_plot <- plot_evpi(evpi, decision_vars = "NPV_decision_do")
## NULL
compound_fig <- compound_figure(mcSimulation_object = mcSimulation_results,
input_table = input_table,
plsrResults = pls_result,
EVPIresults = evpi,
decision_var_name = "NPV_decision_do",
cashflow_var_name = "Cashflow_decision_do",
base_size = 7)
Inspiration from other presentations
Suggestions to improve our model
* Orchard size: + Keep applicability to many different situations in minds + Create a number of realistic scenarios * Estimate maximum area one unit can work on \(\Rightarrow\) Set maximum workload as upper boundary + Consider max. speed, max. uninterrupted working hours
Model Framework * Runs for 10 years (Time to be financially feasible) * One sprayer can handle 15 ha
Assigning model variables to variable type
Event (chance_event(), simulate occurrence of random events), either happens or not
Governments concern triggers intervention, which results in the end of the model (less chance to occur for the automated one)
Disease infection, chance might be reduced with better biodiversity. Different severities.
Fix variables
Cost of the machines are given (distribution)
Pesticides is a yearly necessity (distribution of mean over many years)
Time-dependent variables (vv(), value varier function), variables that change with every iteration
Water contamination
Customers
Biodiversity (maybe using a logistic function?)
Fruit sales
Combined variables
Both events are also time dependent, as higher water contamination rises goverments concern and thus an intervention